package yt.kpool.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.king.base.adapter.ViewHolderAdapter;
import com.king.base.adapter.holder.ViewHolder;

import java.util.List;

import yt.kpool.R;
import yt.kpool.bean.RecommendCustomersBean;


/**
 * 分层模式选择适配器
 * Created by Administrator on 2017/7/17.
 */

public class ModeSelectListviewAdapter extends ViewHolderAdapter<RecommendCustomersBean.DataBean> {

    private int selectedId;//选中的id 没有为-1
    public ModeSelectListviewAdapter(Context context, List<RecommendCustomersBean.DataBean> listData) {
        super(context, listData);
    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, RecommendCustomersBean.DataBean dataBean, int position) {
        return layoutInflater.inflate(R.layout.item_mode_select,null);
    }

    @Override
    public void bindViewDatas(ViewHolder holder, RecommendCustomersBean.DataBean dataBean, int position) {
        holder.setText(R.id.tv_content,dataBean.getProportionName());
        if (dataBean.getProportionID()==selectedId)
        {
            //选中的项
            ((TextView)holder.getView(R.id.tv_content)).setTextColor(context.getResources().getColor(R.color.system_color));
            ((ImageView)holder.getView(R.id.iv_check)).setImageDrawable(context.getResources().getDrawable(R.mipmap.radiochecked));

        }else
        {
            ((TextView)holder.getView(R.id.tv_content)).setTextColor(context.getResources().getColor(R.color.black1));
            ((ImageView)holder.getView(R.id.iv_check)).setImageDrawable(context.getResources().getDrawable(R.mipmap.radionochecked));
        }
    }
    /**
     * 设置选中
     * @param id
     */
    public void setSelected(int id)
    {
        selectedId=id;
        notifyDataSetChanged();
    }

    /**
     * 设置选中id
     */
    public int getselectedId() {
        return selectedId;
    }
}
